package com.hlb.ssm.controller;

import com.hlb.ssm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * Created by Administrator on 2016/12/18.
 */
@Controller
public class StudentController {
    @Autowired
    private StudentService studentService;
    @RequestMapping("list")
    public String list(Integer pageNo,Integer pageSize,Map<String,Object>map){
        int pageNum=1;
        int row=10;
        try{
            pageNum=pageNo;
        }catch (Exception e){};
        try{
            row=pageSize;
        }catch (Exception e){};
        map.put("obj",studentService.getPage(pageNum,row));
        return "list";
    }
    @RequestMapping("delete/{id}")
    public String update(@PathVariable("id") Integer id){
        studentService.delete(id);
        return "redirect:/list";
    }
    @RequestMapping("update/{id}")
    public String toupdate(@PathVariable("id" ) Integer id,Map map){
        map.put("obj", studentService.getOne(id));
        return "update";
    }
}
